﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;

namespace PracaInz_v0
{
    class ForestButtonData : Button
    {
        public DataTable TreeDTB { get; set; }
        public DataTable SymulationDTB { get; set; }
        TreeViewSettings _settings;
        int _id;
        string _quality;

        public ForestButtonData(int id, DataTable _treeDT, DataTable _symulationDTB, object style, TreeViewSettings settings, string quality)
        {            
            this.Width = 250;
            this.Height = 30;
            this.Content = "Tree " + (id + 1).ToString();
            this.Style = style as Style;
            this.TreeDTB = _treeDT;
            this.SymulationDTB = _symulationDTB;
            this._settings = settings;
            this._id = id;
            this._quality = quality;

            this.Click += new RoutedEventHandler(ButtonListData_Click);
        }

        void ButtonListData_Click(object sender, RoutedEventArgs e)
        {
            _settings.SelectedTreeData = (this._id + 1).ToString();
            _settings.SelectedTreeQuality = this._quality;
            ShowTreeDataGrid();
            ShowSymulationDataGrid();                       
        }

        async void ShowTreeDataGrid()
        {
            await Task.Run(() => { _settings.DataViewGridTree = this.TreeDTB.DefaultView; });
        }

        async void ShowSymulationDataGrid()
        {
            await Task.Run(() => { _settings.DataViewGridS = this.SymulationDTB.DefaultView; });    
        }

    }
}
